package com.nstar.countdown.view.main.impl
{
	
	import com.nstar.base.controls.AlertFX;
	import com.nstar.base.util.EffectUtils;
	import com.nstar.base.util.StringUtils;
	
	import flash.events.MouseEvent;
	
	import mx.containers.TitleWindow;
	import mx.controls.Button;
	import mx.controls.TextArea;
	import mx.controls.TextInput;
	import mx.events.CloseEvent;
	import mx.events.FlexEvent;

	public class AdviceClass extends TitleWindow
	{
		public var btnSendMail:Button;
		public var btnCancel:Button;
		public var txtTitle:TextInput;
		public var taContent:TextArea;
		
		public function AdviceClass()
		{
			//TODO: implement function
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
			this.addEventListener(CloseEvent.CLOSE,closeHandler);
		}
		
		private function init(event:FlexEvent):void{
			btnSendMail.addEventListener(MouseEvent.CLICK,sendMailHandler);
			btnCancel.addEventListener(MouseEvent.CLICK,closeHandler);
			txtTitle.setFocus();
		}
		
		private function sendMailHandler(event:MouseEvent):void{
			if (validate()){
				//sendmail
			}

		}
		
		//验证数据
		private function validate():Boolean{
			if (StringUtils.isEmpty(txtTitle.text) || 
				StringUtils.isEmpty(taContent.text) ){
				AlertFX.error("必须要输入建议或意见的标题和内容！");
				return false;
			}
			return true;
		}
		
		
		public function closeHandler(event:*):void{
			EffectUtils.moveUpEffect(this);
		}
		
	}
}